package main

import "fmt"

func main() {
	fmt.Println(longestPalindrome("b"))
}

func longestPalindrome(s string) string {
	maxLen := 0
	ans := ""
	if len(s) == 1 {
		ans = s
	}
	for i := range s {
		l := 0
		var ic = i
		if (len(s)-1)/2 < i {
			ic = len(s) - 1 - i
		}
		for j := 1; j <= ic; j++ {
			before, after := s[i-j], s[i+j]
			if before != after {
				break
			}
			l = j
		}
		if l > maxLen {
			maxLen = l
			ans = s[i-l : i+l+1]
		}
	}
	return ans
}
